package cn.rose.base;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @FileName ReadLog.java
 * @Description: 日志读取类
 * @author rose
 * @version 1.0
 * <p>Company: ROSE-SOFT</p>
 * <p>Copyright: Copyright (c) 2011</p>
 */
public class ReadLog {
	
	/**
		//参数说明：最少数量20，最大数量500 空闲时间 1秒(为单例)
		private static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(20, 500, 1,TimeUnit.SECONDS, 
				//缓冲队列为500
				new ArrayBlockingQueue<Runnable>(500),
				//重试添加当前的任务，他会自动重复调用execute()方法
				new ThreadPoolExecutor.CallerRunsPolicy());
	 */
	
	
	private static ThreadPoolExecutor threadPoolTest = new ThreadPoolExecutor(1, 2, 1, TimeUnit.SECONDS,
			new ArrayBlockingQueue<Runnable>(10),
			new ThreadPoolExecutor.CallerRunsPolicy());
	
	public static void main(String[] args) {
		
//		for (int i = 0; i < 200; i++) {
//			final int j = i;
//			Runnable r = new Runnable(){
//				public void run() {
//					System.out.println(j);
//					try {
//						Thread.sleep(2000);
//					} catch (InterruptedException e) {
//						// TODO Auto-generated catch block
//						e.printStackTrace();
//					}
//				}
//			};
//			threadPoolTest.execute(r);
//		}
//		int[] a = new int[25];
//		for (int i = 0; i < a.length; i++) {
//			System.out.println(a[i]);
//		}
//		Integer[] b = new Integer[25];
//		for (int i = 0; i < b.length; i++) {
//			System.out.println(b[i]);
//		}
		
		List list = new ArrayList();
		List list2 = Collections.synchronizedList(list);
		System.out.println(list == list2);
		
		Boolean[] bb = new Boolean[10];
		for (int i = 0; i < bb.length; i++) {
			System.out.println(bb[i]);
		}
		Object o = new Object();
		
	} 
	
	@SuppressWarnings("unchecked")
	public static void test(){
		System.out.println("hello world");
		List list = new ArrayList();
		List synList = Collections.synchronizedList(list);
		System.out.println(list == synList);
		}
			
	
}

